<?php
class Bizprofile_PartnerController extends Zend_Controller_Action {

    public function indexAction() {
        $auth = Zend_Auth::getInstance();
        $user = null;
        if ($auth->hasIdentity()){
            $user = $auth->getIdentity();
            $this->view->assign('user', $user);
        }
        else{
            $this->_redirect($this->view->serverUrl() . $this->view->url(array(), 'bizprofile_auth_login'));
        }
    }

    public function listAction(){		
        $request	   = $this->getRequest();
		$enterprise_id = $request->getParam('enterprise_id');
		
		$auth = Zend_Auth::getInstance();
		$user = $auth->getIdentity();
		
		/**
		* Kiểm tra user đã login hay chưa
		*/
		$isLogin = false;		
		if($auth->hasIdentity()){
			$isLogin = true;
		}
		$this->view->assign('isLogin', $isLogin);
		
		/**
		* Kiểm tra user login có thuộc doanh nghiệp đang xem
		*/
		$isUserOfEnt = false;
		if(isset($user->enterprise->id)){
			if($enterprise_id == $user->enterprise->id){
				$isUserOfEnt = true;
			}
		}
		$this->view->assign('isUserOfEnt', $isUserOfEnt);
		
		$lang = $request->getParam('lang');
		if(isset($enterprise_id) && $enterprise_id > 0){

            $conn = Tomato_Db_Connection::factory()->getMasterConnection();
            $enterpriseDao  = Tomato_Model_Dao_Factory::getInstance()->setModule('enterprise')->getEnterpriseDao();
            $enterpriseDao->setDbConnection($conn);
			
			$recommentDao  = Tomato_Model_Dao_Factory::getInstance()->setModule('bizprofile')->getPartnerDao();
			$recommentDao->setDbConnection($conn);
				
			/**
			 * Condition
			**/
			$lang_code = ($request->getParam('lang_code'))?$request->getParam('lang_code'):null;
			$this->view->assign('lang_code', $lang_code);
			
			
            $enterprise = $enterpriseDao->getById($enterprise_id);
            $this->view->assign('enterprise', $enterprise);
			$this->view->assign('user', $user);
			
            if (isset($enterprise)){
                $partnerDao = Tomato_Model_Dao_Factory::getInstance()->setModule('bizprofile')->getPartnerDao();
                $partnerDao->setDbConnection($conn);

                $pageIndex     = $request->getParam('pageIndex', 1);
                $perPage = 5;
                $offset     = ($pageIndex - 1) * $perPage;
                $exp = array(
                    'relationid'     => $enterprise_id,
                    'partner_type'   => 'buddy',
                    'partner_status' => 'yes',
		    'deleted'        => 0
                );
			
                /**
                * In ralationship
                **/
                $partners = $partnerDao->find($offset, $perPage, $exp);
                $numPartners   = $partnerDao->count($exp);
				
				/**
				* Paginator
				*/
                $paginator = new Zend_Paginator(new Tomato_Utility_PaginatorAdapter($partners, $numPartners));
                $paginator->setCurrentPageNumber($pageIndex);
                $paginator->setItemCountPerPage($perPage);

                /*$params = $request->getParam('enterprise_id');
                if ($params != null) {
                    $exp = rawurldecode(base64_decode($params));
                    $exp = Zend_Json::decode($exp);
                } else {
                    $params = rawurlencode(base64_encode(Zend_Json::encode($exp)));
                }*/
                $params = null;
                if ($partners != null){
                    $this->view->assign('partners', $partners);
                    $this->view->assign('paginator', $paginator);

                    $arrRoute = array(
                        'enterprise_id' => $enterprise->id,
                        'enterprise_name' => Tomato_Utility_String::removeSign($enterprise->company_name_en, '-', true)
                    );
                    $this->view->assign('paginatorOptions', array(
                        'path'        => $this->view->url($arrRoute, 'bizprofile_partner_list'),
                        'itemLink' => (null == $params)
                                    ? 'page-%d'
                                    : 'page-%d/' . '?enterprise_id=' . $params,
                    ));
                }
				
				/**
				* Lấy recomment của đối tác đối với doanh nghiệp của mình
				* @author:Hung
				*/	
				$recomment = array();
				foreach($partners as $row):
					$expRecomment = array(
						'relationid' => $row->relationid,
						'enterprise_id' => $row->enterprise_id,
					);
					$recomment[$row->enterprise_id] = $recommentDao->find(null, null, $expRecomment);
				endforeach;
				$this->view->assign('recomments', $recomment);
				
				/**
				* Lấy recomment doanh nghiệp của mình cho đối tác
				* @author:Hung
				*/
				$replyRecomment	= array();
				foreach($partners as $row):
					$expReplyRecomment = array(
						'relationid' => $row->enterprise_id,
						'enterprise_id' => $row->relationid,
					);
					$replyRecomment[$row->enterprise_id] = $recommentDao->find(null, null, $expReplyRecomment);
				endforeach;
				$this->view->assign('replyRecomments', $replyRecomment);
			}
		}
		
		/** Khanh *****************************************************************************************************
	    * Kiem tra la user chua login, hay user da login, la DN khach, hay DN doi tac
	    * $user_entity = 1 : User chua login
	    * $user_entity = 2 : User da login, nhung ko la DN
	    * $user_entity = 3 : User da login, la DN khach
	    * $user_entity = 4 : User da login, la DN doi tac
	    **/
        $user_entity = 'none';
        $params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
		$permissionDao = Tomato_Model_Dao_Factory::getInstance()->setModule('bizprofile')->getPermissionDao();
		$permissionDao->setDbConnection($conn);
        //$auth = Zend_Auth::getInstance();
		if ($auth->hasIdentity()) 
		{ 
		    $user = $auth->getIdentity();
		    if(!isset($user->enterprise->id))
		    {
		      	$user_entity = 2; // user da login, nhung ko phai la DN
		    }
			else
			{
				$partnerDao = Tomato_Model_Dao_Factory::getInstance()->setModule('bizprofile')->getPartnerDao();
				$partnerDao->setDbConnection($conn);

				$pageIndex     = 1;
				$perPage = 5;
				$offset     = ($pageIndex - 1) * $perPage;
				$exp = array(
					'relationid' 	 => $params['enterprise_id'],
					'partner_type' 	 => 'buddy',
					'partner_status' => 'yes',
					'deleted'		 => 0
				);						
				//* In ralationship
				$partners = $partnerDao->find($offset, $perPage, $exp);
				$numPartners   = $partnerDao->count($exp);

				if($user->enterprise->id == $enterprise_id) $user_entity = 0;
				else{							
					if($numPartners>0){
						$user_entity = 3;// DN khach
						foreach($partners as $row){
							$expRecomment = array(
								'relationid' => $row->relationid,
								'enterprise_id' => $row->enterprise_id, // DN doi tac
							);
							if($user->enterprise->id == $row->enterprise_id)
							{
								$user_entity = 4; // DN doi tac
							}
						}
					}
				}								
			}
		}
		else 
		{
		   	$user_entity = 1; // user chua login 
		}
			
		$this->view->assign('user_entity', $user_entity);
			
		$permission = $permissionDao->getPermissionByUserEntity($enterprise_id, $user_entity);
		if($permission != null){
			$permission->enterprise_info = unserialize($permission->enterprise_info);			
			$this->view->assign('permission', $permission);
		}
    	if ($auth->hasIdentity()) { 
	            $user = $auth->getIdentity();
				if($user->enterprise){
					if($user->enterprise->id == $enterprise_id) // user đã login thuộc DN đang xem
			    	{
			    		$permission_viewall = 1;
			    		$this->view->assign('permission_viewall', $permission_viewall);
			    	}
				}
        	}
			
		/**
		* END : Kiem tra la user chua login, hay user da login, la DN khach, hay DN doi tac
		*****************************************************************************************************/
        $countRecomment = 0;
        if($isUserOfEnt){                      
            $exp = array(
				'relationid'  => $request->getParam("enterprise_id",null),
				'notify' 		 => 'unview',
                'partner_status' => 'yes',
				'recomment'		 => true	
            );
			$countRecomment  = $partnerDao->count($exp);
        }
        $this->view->assign('countRecomment', $countRecomment);		
    }

    public function waitingAction(){
		$request	   = $this->getRequest();
		$enterprise_id = $request->getParam('enterprise_id');
		$enterprise_name = $request->getParam('enterprise_name');
		$auth = Zend_Auth::getInstance();
		$user = $auth->getIdentity();
		/**
		* Kiểm tra user đã login hay chưa
		*/
		$isLogin = false;		
		if($auth->hasIdentity()){
			$isLogin = true;
		}
		$this->view->assign('isLogin', $isLogin);
		
		/**
		* Kiểm tra user login có thuộc doanh nghiệp đang xem
		*/
		$isUserOfEnt = false;
		if(isset($user->enterprise->id)){
			if($enterprise_id == $user->enterprise->id){
				$isUserOfEnt = true;
			}
		}
		$this->view->assign('isUserOfEnt', $isUserOfEnt);
		
		/**
		* Kiểm tra khi user chưa login hoặc user không thuộc doanh nghiệp đang xem thì không cho vào
		*/
		if(!$isLogin || !$isUserOfEnt){
			$arrEntRoute = array(
				'enterprise_id'   => $enterprise_id,
				'enterprise_name' => $enterprise_name
			);
			$this->_redirect($this->view->serverUrl().$this->view->url($arrEntRoute, 'bizprofile_partner_list') );
		}
				
		if(isset($enterprise_id) && $enterprise_id > 0){

            $conn = Tomato_Db_Connection::factory()->getMasterConnection();
            $enterpriseDao  = Tomato_Model_Dao_Factory::getInstance()->setModule('enterprise')->getEnterpriseDao();
            $enterpriseDao->setDbConnection($conn);
            $enterprise = $enterpriseDao->getById($enterprise_id);
            $this->view->assign('enterprise', $enterprise);

            if (isset($enterprise)){
                $partnerDao = Tomato_Model_Dao_Factory::getInstance()->setModule('bizprofile')->getPartnerDao();
                $partnerDao->setDbConnection($conn);

                $pageIndex     = $request->getParam('pageIndex', 1);
                $perPage = 5;
                $offset     = ($pageIndex - 1) * $perPage;
                $exp = array(
                    'relationid' => $enterprise_id,
                    'partner_type' => 'buddy',
                    'partner_status' => 'no'
                );

                /**
                * In ralationship
                **/
                $partners = $partnerDao->find($offset, $perPage, $exp);
                $numPartners   = $partnerDao->count($exp);

                $paginator = new Zend_Paginator(new Tomato_Utility_PaginatorAdapter($partners, $numPartners));
                $paginator->setCurrentPageNumber($pageIndex);
                $paginator->setItemCountPerPage($perPage);

                /*$params = $request->getParam('enterprise_id');
                if ($params != null) {
                    $exp = rawurldecode(base64_decode($params));
                    $exp = Zend_Json::decode($exp);
                } else {
                    $params = rawurlencode(base64_encode(Zend_Json::encode($exp)));
                }*/
                $params = null;

                if ($partners != null){
                    $this->view->assign('partners', $partners);
                    $this->view->assign('paginator', $paginator);

                    $arrRoute = array(
                        'enterprise_id' => $enterprise->id,
                        'enterprise_name' => Tomato_Utility_String::removeSign($enterprise->company_name_en, '-', true)
                    );
                    $this->view->assign('paginatorOptions', array(
                        'path'        => $this->view->url($arrRoute, 'bizprofile_partner_waiting'),
                        'itemLink' => (null == $params)
                                    ? 'page-%d'
                                    : 'page-%d/' . '?enterprise_id=' . $params,
                    ));
                }
            }
        }		
    }

    public function pendingAction(){
        $request	   = $this->getRequest();
		$enterprise_id = $request->getParam('enterprise_id');
		
		$auth = Zend_Auth::getInstance();
		$user = $auth->getIdentity();
		
		
		$isLogin = false;		
		if($auth->hasIdentity()){
			$isLogin = true;
		}
		$this->view->assign('isLogin', $isLogin);
		
		/**
		* Kiểm tra user login có thuộc doanh nghiệp đang xem
		*/
		$isUserOfEnt = false;
		if(isset($user->enterprise->id)){
			if($enterprise_id == $user->enterprise->id){
				$isUserOfEnt = true;
			}
		}
		$this->view->assign('isUserOfEnt', $isUserOfEnt);
		
		/**
		* Kiểm tra khi user chưa login hoặc user không thuộc doanh nghiệp đang xem thì không cho vào
		*/
		if(!$isLogin || !$isUserOfEnt){
			$arrEntRoute = array(
				'enterprise_id'   => $enterprise_id,
				'enterprise_name' => $enterprise_name
			);
			$this->_redirect($this->view->serverUrl().$this->view->url($arrEntRoute, 'bizprofile_partner_list') );
		}
		
        if(isset($enterprise_id) && $enterprise_id > 0){

            $conn = Tomato_Db_Connection::factory()->getMasterConnection();
            $enterpriseDao  = Tomato_Model_Dao_Factory::getInstance()->setModule('enterprise')->getEnterpriseDao();
            $enterpriseDao->setDbConnection($conn);
            $enterprise = $enterpriseDao->getById($enterprise_id);
            $this->view->assign('enterprise', $enterprise);

            if (isset($enterprise)){
                $partnerDao = Tomato_Model_Dao_Factory::getInstance()->setModule('bizprofile')->getPartnerDao();
                $partnerDao->setDbConnection($conn);

                $pageIndex     = $request->getParam('pageIndex', 1);
                $perPage = 5;
                $offset     = ($pageIndex - 1) * $perPage;
                $exp = array(
                    'relationid' => $enterprise_id,
                    'partner_type' => 'buddy',
                    'partner_status' => 'pending'
                );

                /**
                * In ralationship
                **/
                $partners = $partnerDao->find($offset, $perPage, $exp);
                $numPartners   = $partnerDao->count($exp);

                $paginator = new Zend_Paginator(new Tomato_Utility_PaginatorAdapter($partners, $numPartners));
                $paginator->setCurrentPageNumber($pageIndex);
                $paginator->setItemCountPerPage($perPage);

                /*$params = $request->getParam('enterprise_id');
                if ($params != null) {
                    $exp = rawurldecode(base64_decode($params));
                    $exp = Zend_Json::decode($exp);
                } else {
                    $params = rawurlencode(base64_encode(Zend_Json::encode($exp)));
                }*/
                $params = null;

                if ($partners != null){
                    $this->view->assign('partners', $partners);
                    $this->view->assign('paginator', $paginator);

                    $arrRoute = array(
                        'enterprise_id' => $enterprise->id,
                        'enterprise_name' => Tomato_Utility_String::removeSign($enterprise->company_name_en, '-', true)
                    );
                    $this->view->assign('paginatorOptions', array(
                        'path'        => $this->view->url($arrRoute, 'bizprofile_partner_pending'),
                        'itemLink' => (null == $params)
                                    ? 'page-%d'
                                    : 'page-%d/' . '?enterprise_id=' . $params,
                    ));
                }
            }
        }
    }

    /**
    * Register an enterprise
    *
    */
    public function addPartnerAction(){

        $this->_helper->getHelper('viewRenderer')->setNoRender();
        $this->_helper->getHelper('layout')->disableLayout();

        $request = $this->getRequest();

        $conn = Tomato_Db_Connection::factory()->getMasterConnection();

        /**
         * Partner model access to data
         **/
        $partnerDao = Tomato_Model_Dao_Factory::getInstance()->setModule('bizprofile')->getPartnerDao();
        $partnerDao->setDbConnection($conn);

        $enterprise_id  = $request->getPost('enterprise_id');
        $relation_id  = $request->getPost('relation_id');
		$redirect_url   = $request->getPost('redirect_url',null);
		
        if(isset($enterprise_id) && $enterprise_id > 0 && isset($relation_id) && $relation_id > 0){
            $auth = Zend_Auth::getInstance();
            if (!$auth->hasIdentity()) {
                $this->_redirect($this->view->serverUrl() . $this->view->url(array(), 'bizprofile_auth_login'));
            }
            $user = $auth->getIdentity();
            if(!$user->enterprise || ($user->enterprise_id != $enterprise_id)){
                if ($request->isPost()) {
                    if (!$partnerDao->checkPartner($enterprise_id, $relation_id)){
                        $partner = new Bizprofile_Models_Partner(array(
                            'enterprise_id'     => $enterprise_id,
                            'relationid'        => $relation_id,
                            'partner_type'      => "buddy",
                            'partner_status'    => "pending",
							'notify'		    => "unview"
                        ));
                        $partnerDao->add($partner);
                    }
                    if (!$partnerDao->checkPartner($relation_id, $enterprise_id)){
                        $partner = new Bizprofile_Models_Partner(array(
                            'enterprise_id'     => $relation_id,
                            'relationid'        => $enterprise_id,
                            'partner_type'      => "buddy",
                            'partner_status'    => "no",
							'notify'		    => "unview"
                        ));
                        $partnerDao->add($partner);
                    }
                }
            }
        }
        else{
            $enterprise_id = 0;
        }
        $arrParamPartner = array(
            'enterprise_id' => $user->enterprise->id,
            'enterprise_name' => Tomato_Utility_String::removeSign($user->enterprise->company_name_en, '-', true)
        );
		if($redirect_url){
			$this->_redirect($this->view->serverUrl() . $redirect_url);
		}
		else
			$this->_redirect($this->view->serverUrl() . $this->view->url($arrParamPartner, 'bizprofile_partner_list'));
    }
    public function deniedPartnerAction(){
        $this->_helper->getHelper('viewRenderer')->setNoRender();
        $this->_helper->getHelper('layout')->disableLayout();

        $request = $this->getRequest();

        $conn = Tomato_Db_Connection::factory()->getMasterConnection();

        /**
         * Partner model access to data
         **/
        $partnerDao = Tomato_Model_Dao_Factory::getInstance()->setModule('bizprofile')->getPartnerDao();
        $partnerDao->setDbConnection($conn);

        $enterprise_id  = $request->getPost('enterprise_id');
        $relation_id    = $request->getPost('relation_id');
		$redirect_url   = $request->getPost('redirect_url',null);

        if(isset($enterprise_id) && $enterprise_id > 0 && isset($relation_id) && $relation_id > 0){
            $auth = Zend_Auth::getInstance();
            if (!$auth->hasIdentity()) {
                $this->_redirect($this->view->serverUrl() . $this->view->url(array(), 'bizprofile_auth_login'));
            }
            $user = $auth->getIdentity();
            if(!$user->enterprise || ($user->enterprise_id != $enterprise_id)){
                if ($request->isPost()) {
                    $partnerDao->denyPartner($enterprise_id, $relation_id);
                }
                $arrParamPartner = array(
                    'enterprise_id' => $user->enterprise->id,
                    'enterprise_name' => Tomato_Utility_String::removeSign($user->enterprise->company_name_en, '-', true)
                );
				if($redirect_url){
					$this->_redirect($this->view->serverUrl() . $redirect_url);
				}
				else
					$this->_redirect($this->view->serverUrl() . $this->view->url($arrParamPartner, 'bizprofile_partner_list'));
            }
        }
    }
    public function confirmPartnerAction(){

        $this->_helper->getHelper('viewRenderer')->setNoRender();
        $this->_helper->getHelper('layout')->disableLayout();

        $request = $this->getRequest();

        $conn = Tomato_Db_Connection::factory()->getMasterConnection();

        /**
         * Partner model access to data
         **/
        $partnerDao = Tomato_Model_Dao_Factory::getInstance()->setModule('bizprofile')->getPartnerDao();
        $partnerDao->setDbConnection($conn);

        $enterprise_id  = $request->getPost('enterprise_id');
        $relation_id    = $request->getPost('relation_id');
		$redirect_url   = $request->getPost('redirect_url',null);
		
        if(isset($enterprise_id) && $enterprise_id > 0 && isset($relation_id) && $relation_id > 0){
            $auth = Zend_Auth::getInstance();
            if (!$auth->hasIdentity()) {
                $this->_redirect($this->view->serverUrl() . $this->view->url(array(), 'bizprofile_auth_login'));
            }
            $user = $auth->getIdentity();
            if(!$user->enterprise || ($user->enterprise_id != $enterprise_id)){
                if ($request->isPost()) {

                    $partnerDao->acceptPartner($enterprise_id, $relation_id);
                }
                $arrParamPartner = array(
                    'enterprise_id' => $user->enterprise->id,
                    'enterprise_name' => Tomato_Utility_String::removeSign($user->enterprise->company_name_en, '-', true)
                );
				if($redirect_url){
					$this->_redirect($this->view->serverUrl() . $redirect_url);
				}
				else
					$this->_redirect($this->view->serverUrl() . $this->view->url($arrParamPartner, 'bizprofile_partner_list'));
            }
        }
    }

    public function removePartnerAction(){
        $request = $this->getRequest();

        $conn = Tomato_Db_Connection::factory()->getMasterConnection();

        /**
         * Partner model access to data
         **/
        $partnerDao = Tomato_Model_Dao_Factory::getInstance()->setModule('bizprofile')->getPartnerDao();
        $partnerDao->setDbConnection($conn);
        $auth = Zend_Auth::getInstance();
        if (!$auth->hasIdentity()) {
            $this->_redirect($this->view->serverUrl() . $this->view->url(array(), 'bizprofile_auth_login'));
        }
        $user = $auth->getIdentity();
        $enterprise_id  = $request->getPost('enterprise_id');
        $relation_id  = $request->getPost('relation_id');
		$partnerAction = $request->getPost('partnerAction');
		$redirect_url  = $request->getPost('redirect_url',null);
        if(isset($enterprise_id) && $enterprise_id > 0 && isset($relation_id) && $relation_id > 0){
            if(!$user->enterprise || ($user->enterprise_id != $enterprise_id)){
                if ($request->isPost()) {
                    $partnerDao->removePartner($enterprise_id, $relation_id);
                    $partnerDao->removePartner($relation_id, $enterprise_id);
                }				
				if($redirect_url){
					$this->_redirect($this->view->serverUrl() . $redirect_url);
				}				
                $arrParamPartner = array(
                    'enterprise_id' => $user->enterprise->id,
                    'enterprise_name' => Tomato_Utility_String::removeSign($user->enterprise->company_name_en, '-', true)
                );
				if($partnerAction == 'list'){				
					$this->_redirect($this->view->serverUrl() . $this->view->url($arrParamPartner, 'bizprofile_partner_list'));
				}
				if($partnerAction == 'waiting'){				
					$this->_redirect($this->view->serverUrl() . $this->view->url($arrParamPartner, 'bizprofile_partner_waiting'));
				}
				if($partnerAction == 'pending'){				
					$this->_redirect($this->view->serverUrl() . $this->view->url($arrParamPartner, 'bizprofile_partner_pending'));
				}
            }
        }
    }

    public function notifyShowAction(){
        $this->_helper->getHelper('viewRenderer')->setNoRender();
        $this->_helper->getHelper('layout')->disableLayout();
        $this->_redirect($this->view->serverUrl().$this->view->url(array(), 'bizprofile_partner_notify'));
    }

    public function notifyAction(){
        $auth = Zend_Auth::getInstance();
        if ($auth->hasIdentity()) {
            $user = $auth->getIdentity();
            if($user->enterprise){
                $conn = Tomato_Db_Connection::factory()->getMasterConnection();
                $partnerDao = Tomato_Model_Dao_Factory::getInstance()->setModule('bizprofile')->getPartnerDao();
                $partnerDao->setDbConnection($conn);
                $partnerDao->updateNotify($user->enterprise->id);
                $arrParamPartner = array(
                    'enterprise_id' => $user->enterprise->id,
                    'enterprise_name' => Tomato_Utility_String::removeSign($user->enterprise->company_name_en, '-', true)
                );
                $this->_redirect($this->view->serverUrl() . $this->view->url($arrParamPartner, 'bizprofile_partner_list'));
                //$this->_redirect($this->view->serverUrl() . $this->view->url(array(), 'bizprofile_partner_list') . '?enterprise_id='. $user->enterprise->id);
            }
        }
        $this->_redirect($this->view->serverUrl() . $this->view->url(array(), 'bizprofile_auth_login'));
    }
	
	public function recommentAction(){
		$this->_helper->getHelper('layout')->disableLayout();
		$this->_helper->getHelper('viewRenderer')->setNoRender();
		
		$data = $this->getRequest()->getParams();
		$recomment = array();
		
		$conn = Tomato_Db_Connection::factory()->getMasterConnection();
		$recommentDao = Tomato_Model_Dao_Factory::getInstance()->setModule('bizprofile')->getPartnerDao();
		$recommentDao->setDbConnection($conn);
		
		$recomment["relationid"] 		= $data['relation_id'];
		$recomment["enterprise_id"]     = $data['enterprise_id'];
		$recomment["recomment"]		    = $data['content'];
		
		$result = $recommentDao->updaterecomment($recomment);		
		
		echo $recomment['recomment']; 
		die;		
	}
}